/* 
 * File:   GraficoTest.cpp
 * Author: max
 *
 * Created on Oct 6, 2012, 2:39:10 PM
 */

#include <stdlib.h>
#include <iostream>
#include <Grafico.h>
#include <Figura.h>
#include <FiguraException.h>
#include <FiguraFactory.h>
#include <FiguraFactoryException.h>


using namespace TP::Grafica;
using namespace TP::Grafica::Componentes;
using namespace TP::Colecciones;

/*
 * Simple C++ Test Suite
 */

void test1() {

    std::cout << "GraficoTest test 1" << std::endl;
    
    Lista figuras;
    
    try
    {
        FiguraFactory factory;

        /* Salida 2*/
        figuras.Agregar(factory.crear("V:9,9,6"));
        figuras.Agregar(factory.crear("R:44,9,3"));
        figuras.Agregar(factory.crear("C:79,9,6"));
        figuras.Agregar(factory.crear("L:9,9,3"));
        figuras.Agregar(factory.crear("L:9,43,3"));
        figuras.Agregar(factory.crear("L:44,43,3"));

        /* Salida 2*/
        /*
         figuras.Agregar(factory.crear("V:9,0,6"));
        figuras.Agregar(factory.crear("L:9,0,3"));
        figuras.Agregar(factory.crear("L:44,0,3"));
        figuras.Agregar(factory.crear("L:79,0,3"));
        figuras.Agregar(factory.crear("L:109,0,3"));
        figuras.Agregar(factory.crear("R:55,34,0"));
        figuras.Agregar(factory.crear("R:144,34,0"));
        figuras.Agregar(factory.crear("L:9,35,6"));
        figuras.Agregar(factory.crear("L:55,35,3"));
        figuras.Agregar(factory.crear("L:144,35,9"));
        figuras.Agregar(factory.crear("P:55,35,6"));
        figuras.Agregar(factory.crear("R:144,35,6"));
        figuras.Agregar(factory.crear("L:9,69,3"));
        figuras.Agregar(factory.crear("L:44,69,3"));
        figuras.Agregar(factory.crear("L:79,69,3"));
        figuras.Agregar(factory.crear("L:109,69,3"));
         */

        Grafico grafico;
        
        IGraficable* grafica = (IGraficable*) figuras.Primero();
        while (NULL != grafica)
        {
            grafico.addGraficable(grafica);
            grafica = (IGraficable*) figuras.Siguiente(grafica);
        }
        
        BMP* imagen = grafico.toBMP();
        ofstream out ("/home/Max/facultad/75.12.TallerProg/TPs/TP3/Fuentes/TP3/GraficoTestOut.bmp");
        out << *imagen;
        out.close();
        delete imagen;
    }
    catch (FiguraException& pEx)
    {
        std::cout << "%TEST_FAILED% time=0 testname=test1 (GraficoTest) message=FiguraException. " << pEx.what() << std::endl;
    }
    catch (FiguraFactoryException& pEx)
    {
        std::cout << "%TEST_FAILED% time=0 testname=test1 (GraficoTest) message=FiguraFactoryException. " << pEx.what() << std::endl;
    }
    catch (exception& pEx)
    {
        std::cout << "%TEST_FAILED% time=0 testname=test1 (GraficoTest) message=Exception. " << pEx.what() << std::endl;
    }
    
}

void test2() {
    std::cout << "GraficoTest test 2" << std::endl;
    std::cout << "%TEST_FAILED% time=0 testname=test2 (GraficoTest) message=error message sample" << std::endl;
}

int main(int argc, char** argv) {
    std::cout << "%SUITE_STARTING% GraficoTest" << std::endl;
    std::cout << "%SUITE_STARTED%" << std::endl;

    std::cout << "%TEST_STARTED% test1 (GraficoTest)" << std::endl;
    test1();
    std::cout << "%TEST_FINISHED% time=0 test1 (GraficoTest)" << std::endl;

    std::cout << "%TEST_STARTED% test2 (GraficoTest)\n" << std::endl;
    test2();
    std::cout << "%TEST_FINISHED% time=0 test2 (GraficoTest)" << std::endl;

    std::cout << "%SUITE_FINISHED% time=0" << std::endl;

    return (EXIT_SUCCESS);
}

